<template>
  <Echart :height="height" width="100%" :options="options" />
</template>

<script>
import Echart from '@/components/Echart/index'
// import resize from '@/utils/resize'
export default {
  components: { Echart },
  // mixins: [resize],
  props: {
    cdata: {
      type: Object,
      default() {
        return {}
      }
    },
    height: {
      type: String,
      default() {
        return '100%'
      }
    }
  },
  data() {
    return {
      chart: null,
      options: {
        color: ['#4b6eef', '#3abf81'],
        tooltip: {
          trigger: 'item'
        },
        legend: {
          show: true,
          bottom: '0%',
          left: 'center',
          orient: 'vertical',
          icon: 'circle',
          itemWidth: 10
        },
        series: [
          {
            name: '',
            type: 'pie',
            center: ['50%', '30%'],
            radius: ['40%', '60%'],
            avoidLabelOverlap: false,
            label: {
              show: false,
              position: 'inside',
              formatter(params) {
                return params.percent + '%'
              }
            },
            emphasis: {
              label: {
                show: false,
                fontSize: '20',
                fontWeight: 'bold'
              }
            },
            labelLine: {
              show: false
            },
            data: [
              { value: 1048, name: '特别重大' },
              { value: 735, name: '重大' },
              { value: 580, name: '较大' },
              { value: 484, name: '一般' }
            ]
          }
        ]
      }
    }
  },
  watch: {
    cdata: {
      handler(newValue) {
        this.options.legend.show = newValue.legendShow
        this.options.color = newValue.color
        this.options.series[0].data = newValue.data
      },
      immediate: true,
      deep: true
    }
  }
}
</script>
